package samples.d2.shapes 
{
	import flash.filters.DropShadowFilter;
	import flash.filters.GlowFilter;
	import flash.geom.Rectangle;
	import flash.utils.setInterval;
	import samples.BaseSample;
	import shapes.shapes2D.distribution.goldenRatio.GoldenRatio;
	import shapes.shapes2D.distribution.Grid;
	import shapes.shapes2D.Dot;
	import shapes.shapes2D.Square;
	
	/**
	 * @author Nicolas Barradeau
	 * http://en.nicoptere.net
	 */
	public class Square8 extends BaseSample
	{
		private var s:Square;
		public function Square8() 
		{
			
			s = new Square(0, 0, 0);
			reset();
			
		}
		
		private function reset():void
		{
			var i:int;
			for (i = 100; i < sw - 100; i+=100 )
			{
				
				pattern( i, sh / 2 - 100, 100 );
				
			}
		}
		
		private function pattern( x:Number, y:Number, size:Number = 10  ):void
		{
			var motif:Array = [
								"111111111111111",
								"111110000011111",
								"111000000000111",
								"110000000000011",
								"100000000000001",
								"111000000000111",
								"110000000000011",
								"100000000000001",
								"100000000000001",
								"100000000000001",
								"100000000000001",
								"100000000000001",
								"100000000000001",
								"100000000000001",
								"100000000000001",
								"100000000000001",
								"100000000000001",
								"100000000000001",
								"100000000000001",
								"100000000000001",
								"110000000000011",
								"111111111111111",
								"100011000110001",
								"001010010100101",
								"011000110001100",
								"111111111111111"
								];
			
			
			var width:Number = motif[ 0 ].length;
			var height:Number = motif.length;
			
			var step:Number = s.size = ( size / width );
			
			graphics.lineStyle( 0,0 );
			graphics.beginFill( color );
			
			var i:int, j:int;
			
			for ( i = 0; i < height; i++ )
			{
						
				for ( j = 0; j < width; j++ )
				{
					if ( motif[ i ].charAt( j ) == '1' )
					{
						s.x = x + j * step;
						s.y = y + i * step;
						s.draw( graphics );
					}
				}
			}
			
		}
		
	}

}